@include('../header')

<div class="body_bg">
	<div class="container">
		<!-- 主列表 -->
		<ul class="ul_nav left">
			<li >
				<a class="li_01 " href="/invitation/1/edit">编辑喜帖</a>
			</li>
			<li >
				<a class="li_02" href="/invitation/list">查看喜帖</a>
			</li>
			<li >
				<a class="li_04 " href="/invitation/bless">祝福留言</a>
			</li>
			<li class="active">
				<a class="li_05 active" href="/invitation/attend">出席名单</a>
			</li>
		</ul>
		<div class="left container_box">
			<div class="tit">
				<p>
					<a id="three1" class="active" href="">出席名单</a>
				</p>
			</div>
			<div id="attend_list" class="table">
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
    //出席名单
    $.ajax({
        type: "GET",
        url:'/api/v1/attend',
        success: function(data) {
        	if (!data.error) {
              	var attended= data.result;
              	var invitation = new Array();
              	for (var i = attended.length - 1; i >= 0; i--) {
              		if (!$.inArray(attended[i].invitation_id, invitation)) {
              			var blehtml  = '<tr>\
			                <td>'+attended[i].name+'</td>\
			                <td>'+attended[i].phone+'</td>\
			                <td>'+attended[i].number+'</td>\
			                <td>'+attended[i].create_at+'</td>\
			                </tr>';
			            $("#attend_"+attended[i].invitation_id).append(blehtml);
              		}else{
              			invitation.push(attended[i].invitation_id);
          			    var bletit = '<div class="bless_box">\
                            <div class="bless_tit">\
                              <p class="left">新郎：<span class="man_name">'+attended[i].boy_name+'</span></p>\
                              <p class="right">新娘：<span class="women_name">'+attended[i].girl_name+'</span></p>\
                            </div>\
                            <table id="attend_'+attended[i].invitation_id+'">\
                              <tr>\
                                <th>姓名</th>\
                                <th>电话</th>\
                                <th>出席人数</th>\
                                <th>回复时间</th>\
                              </tr>\
                            </table>\
                          </div>';
            			$('#attend_list').append(bletit);
                  var blehtml  = '<tr>\
                      <td>'+attended[i].name+'</td>\
                      <td>'+attended[i].phone+'</td>\
                      <td>'+attended[i].number+'</td>\
                      <td>'+attended[i].create_at+'</td>\
                      </tr>';
                  $("#attend_"+attended[i].invitation_id).append(blehtml);
              		};
              		
              	};
              };
        }
    }); 
</script>
@include('../footer')